<?php
/*----------------------------------------------------------------------
 * 公共业务控制器
 * Author: ming.nie
----------------------------------------------------------------------*/

namespace Home\Controller;
use Think\Controller;

class CommonController extends Controller
{
    public function index()
    {
        echo 'common ...';
    }
    
    /**
     * 财务结算定时脚本，结算上一个月的数据
     */
    public function doBillSettlement()
    {
       //注：结算时间设置应当避免在月底，否则会出现大小月，平闰年的问题
       echo D('Common/Bill')->doSettlement(date('Y-m-d',strtotime('last month')));
    }
    
    /**
     * 财务结算同步到影院
     */
    public function doBillsync()
    {
        echo D('Common/Bill')->sync();
    }

    /**
     * 扫描试用中的用户，如果试用到期，就更新状态为非试用，且清空试用时间
     */
    public function clearTryCinemaHosts()
    {
        $commonLogic = new \Common\Logic\CommonLogic();
        $commonLogic->clearTryCinemaHosts();
    }

    /**
     * Kmi播放计费统计
     */
    public function kmiBilling()
    {
        set_time_limit(0); //运算时间较长
        ini_set ('memory_limit', '1024M');
        $kmiCronLogic = new \Common\Logic\KmiCronLogic();
        $kmiCronLogic->billing();
    }

    /**
     * Kmi播放计费规则调整，重新计算
     */
    public function refreshKmiBilling()
    {
        set_time_limit(0); //运算时间较长
        ini_set ('memory_limit', '1024M');
        $kmiCronLogic = new \Common\Logic\KmiCronLogic();
        $kmiCronLogic->refreshKmiBilling();
    }
    public function syncTheatreInfo(){
        $commonLogic = new \Common\Logic\CommonLogic();
        $commonLogic->syncTheatreInfo();
    }
    public function getCinemaList(){
        $commonLogic = new \Common\Logic\CommonLogic();
        $commonLogic->getCinemaList();
    }
}